/* $Id: queue.h 13 2006-12-14 21:07:45Z judas $ */

#ifndef NIH_QUEUE_H
#define NIH_QUEUE_H 1

#include <nih/cdefs.h>

BEGIN_C_DECLS

#include <nih/list.h>
#include <nih/types.h>

#include <stdlib.h>
#include <sys/types.h>

struct nih_queue {
	struct nih_dlist *list;
	struct nih_dlist *last;
	size_t len;
	ssize_t maxlen;
	void *udata;
};

extern struct nih_queue *nih_qcreate_len(ssize_t maxlen);

extern inline struct nih_queue *nih_qcreate()
{
        return nih_qcreate_len(-1);
}

extern int nih_qenq(struct nih_queue *queue, const void *value);

extern int nih_qdeq(struct nih_queue *queue, void **value);

extern int nih_qdestroy_deep(struct nih_queue *queue, nih_free_fnc *free_fnc);

extern inline int nih_qdestroy(struct nih_queue *queue)
{
        return nih_qdestroy_deep(queue, NULL);
}

END_C_DECLS

#endif /* NIH_QUEUE_H */

